<?php
session_start();
include_once 'config.php';
$societes = get_societe();
//print_r($societes);

if (isset($_POST['added'])) {
    add_salarie();
    echo '<a href="/">Back</a>';
} else {
?>
<form method="post" action="add-salarie.php">
    <input type="hidden" name="added" value="1"/>
    <div class="row">
        <label for="nom">Nom</label>
        <input name="nom" id="nom"/>
    </div>
    <div class="row">
        <label for="prenom">Prenom</label>
        <input name="prenom" id="prenom"/>
    </div>
    <?php if ($societes) : ?>
        <div class="row">
            <label for="societe">Societe</label>
            <select id="societe" name="societe">
                <?php foreach( $societes as $so) : ?>
                    <option value="<?php echo $so->id_societe ?>"><?php echo $so->nom ?></option>
                <?php endforeach; ?>
            </select>
        </div>
    <?php endif; ?>
    <div class="row">
        <label for="telephon">Telephon</label>
        <input name="telephon" id="telephon"/>
    </div>
    <div class="row">
        <label for="salaire">Salaire</label>
        <input name="salaire" id="salaire"/>
    </div>
    <input type="submit" value="Save"/>
</form>
<?php
}
